export const defProperty = (obj: GObject, key: keyof GObject, value: any) => {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true,
    });
  } else {
    obj[key] = value;
  }

  return obj;
};

export const rest = (s: any = {}, e: string[]) => {
  let t: GObject = {};
  for (let p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) {
      t[p] = s[p];
    }
  }
  if (s != null && typeof Object.getOwnPropertySymbols === 'function')
    for (
      let i = 0, p: any = Object.getOwnPropertySymbols(s);
      i < p.length;
      i++
    ) {
      if (
        e.indexOf(p[i]) < 0 &&
        Object.prototype.propertyIsEnumerable.call(s, p[i])
      )
        t[p[i]] = s[p[i]];
    }
  return t;
};
